/**
 * Copyright (C) [2019] [NAOC-TJU Lab & NUS Xtra Computing Group]
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version. You may obtain a copy of the License at
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Hao FU (TJU-NUS Joint Ph.D) <haofu@tju.edu.cn>
 */

#ifndef CPU_ONLY

#ifndef __INFO_LOG_H__
#define __INFO_LOG_H__

#include <mutex>
#include <string>
#include <fstream>
#include <unordered_map>

#include <boost/make_shared.hpp>

#include "caffe/macros.hpp"

namespace caffe {
  using std::ofstream;
  using std::string;

  /**
   * @brief A class designed for logging corresponding network information.
   */
  class InfoLog
  {
  public:
    ~InfoLog();
    /**
     * @brief To get a InfoLog object.
     *
     * @return A static InfoLog object
     */
    static InfoLog& Get();

    void Reset();

    void SetRootFolder(string root_folder);

    void SetWorkFolder(string work_folder);

    void RecordInfoLog(string folder, string label_str, string log_type, string log_val);

  protected:
    int device_id_;
    string base_log_folder_;
    string work_folder_;
    ofstream log_stream_;

  private:
    InfoLog();

    DISABLE_COPY_MOVE_AND_ASSIGN(InfoLog);
  };                            // class InfoLog

} // namespace caffe.

#endif /* __INFO_LOG_H__ */

#endif  // CPU_ONLY
